package com.bjqg.bjqg01.bjqg.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bjqg.bjqg01.bjqg.R;

/**
 * Created by bjqg01 on 2017/12/13.
 */

public class OnLinePayActivity extends BaseActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {

    private TextView title;
    private ImageView back;
    private ImageView select;
    private CheckBox id_checkboc_alipay, id_checkboc_wx;
    private TextView btn_pay;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_online_pay);

        initView();
        addListener();
    }

    private void addListener() {
        back.setOnClickListener(this);
        id_checkboc_wx.setOnCheckedChangeListener(this);
        id_checkboc_alipay.setOnCheckedChangeListener(this);
        btn_pay.setOnClickListener(this);
    }

    private void initView() {
        back = (ImageView) findViewById(R.id.back);
        select = (ImageView) findViewById(R.id.select);
        select.setVisibility(View.GONE);
        title = (TextView) findViewById(R.id.tv_top_title);
        title.setText("网上支付");
        id_checkboc_alipay = (CheckBox) findViewById(R.id.id_checkboc_alipay);
        id_checkboc_wx = (CheckBox) findViewById(R.id.id_checkboc_wx);
        btn_pay = (TextView) findViewById(R.id.btn_pay);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.back:
                finish();
                break;
            case R.id.btn_pay:
                Intent intent = new Intent();
//                intent.setClass(this, WXPayEntryActivity.class);
                if (id_checkboc_wx.isChecked()){
                    Toast.makeText(getApplicationContext(),"微信支付",Toast.LENGTH_LONG).show();
                }else if (id_checkboc_alipay.isChecked()){
                    Toast.makeText(getApplicationContext(),"支付宝",Toast.LENGTH_LONG).show();
                }else{
                    Toast.makeText(getApplicationContext(),"请选择支付方式",Toast.LENGTH_LONG).show();
                }
//                startActivity(intent);
                break;
        }
    }

    public void RequestMode() {

//        PostFileRequest postRequest = new PostFileRequest("URL",1,"KEY","",null.null,null).build().buildCall(new Callback() {
//            @Override
//            public Object parseNetworkResponse(Response response, int id) throws Exception {
//                return null;
//            }
//
//            @Override
//            public void onError(Call call, Exception e, int id) {
//
//            }
//
//            @Override
//            public void onResponse(Object response, int id) {
//
//            }
//        });

    }



    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

        if (buttonView == id_checkboc_wx) {
            if (isChecked) {
                id_checkboc_wx.setChecked(true);
                id_checkboc_alipay.setChecked(false);
            }
        } else if (buttonView == id_checkboc_alipay) {
            if (isChecked) {
                id_checkboc_wx.setChecked(false);
                id_checkboc_alipay.setChecked(true);
            }
        }
    }
}
